from flask import Flask
app = Flask(__name__)

# class HttpMgr:
#     def __init__(self):
#

@app.route('/')
def hello():
    return 'Hello, World!'

def start():
    global app
    app.run(host='0.0.0.0', port=30100)


from flask import Flask, request, Response
import requests

app = Flask(__name__)

@app.route('/stream_audio', methods=['POST'])
def stream_audio():
    text = request.form.get('text')
    if not text:
        return "Missing text", 400

    # 假设 stream_audio_url 是你音频生成API的URL
    stream_audio_url = 'http://audio-api-server/stream_audio'
    resp = requests.post(stream_audio_url, data={'text': text}, stream=True)

    def generate():
        for chunk in resp.iter_content(chunk_size=4096):
            yield chunk

    return Response(generate(), mimetype='audio/wav')

if __name__ == '__main__':
    app.run(debug=True)

